Part Number Hot Search : 
EL2082CS C2012 ST89E 0TA5R SK702 ST3P3TP0 UPA1600 KDV240
Product Description
Full Text Search
 

To Download AN3308 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  january 2011 doc id 18198 rev 1 1/52 AN3308 application note lis3dh: mems digital output motion sensor ultra low-power high performance 3-axis ?nano? accelerometer introduction this document describes the low-voltage 3-axis digital output linear mems accelerometer provided in an lga package. the lis3dh is an ultra low-power high performance 3-axis linear accelerometer belonging to the ?nano? family, with a digital i 2 c/spi serial interface standard output. the device features ultra low-power operational modes that allow advanced power saving and smart sleep-to-wake-up and return-to-sleep functions. the lis3dh has dynamic user selectable full scales of 2g/4g/8g/16g and it is capable of measuring accelerations with output data rates from 1 hz to 5 khz. the device may be configured to generate interrupt signals by an independent inertial wake- up/free-fall event as well as by the position of the device itself. thresholds and timing of the interrupt generator are programmable by the end user on the fly. automatic programmable sleep-to-wake-up and return-to-sleep functions are also available for enhanced power saving. the lis3dh has an integrated 32-level first in first out (fifo) buffer allowing the user to store data for host processor intervention reduction. the lis3dh is available in a small thin plasti c land grid array package (lga) and it is guaranteed to operate over an extended temperature range from -40 c to +85 c. the ultra small size and weight of the smd package make it an ideal choice for handheld portable applications such as cell phones and pdas, or any other application where reduced package size and weight are required. www.st.com
contents AN3308 2/52 doc id 18198 rev 1 contents 1 registers table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2 operating modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1 power-down mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2 normal mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.3 low power mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.4 switch mode timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3 startup sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1 reading acceleration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1.1 using the status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.1.2 using the data-ready (dry) signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.1.3 using the block data update (bdu) feature . . . . . . . . . . . . . . . . . . . . . . 13 3.2 understanding acceleration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.1 data alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.2 big-little endian selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.3 example of acceleration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4 high-pass filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.1 filter configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.1.1 normal mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.1.2 reference mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.1.3 autoreset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 5 interrupt generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5.1 interrupt pin configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6 inertial interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.1 duration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 6.2 threshold . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6.3 free-fall and wake-up interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6.3.1 inertial wake-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 6.3.2 hp filter bypassed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
AN3308 contents doc id 18198 rev 1 3/52 6.3.3 using the hp filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 6.4 free-fall detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 7 6d/4d orientation detec tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7.1 6d orientation detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 7.2 4d direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 8 click and double click recognitio n . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 8.1 single click . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 8.2 double click . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 8.3 register description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 8.3.1 tap_cfg (38h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 8.3.2 tap_src (39h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 8.3.3 tap_ths (3ah) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 8.3.4 time_limit (3bh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 8.3.5 time_latency (3ch) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 8.3.6 time window (3dh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 8.3.7 ctrl_reg3 [interrupt ctrl register] (22h) . . . . . . . . . . . . . . . . . . . . 35 8.4 examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 8.4.1 playing with tap_timelimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 8.4.2 playing with tap_latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 8.4.3 playing with tap_window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 9 first in first out (fifo) buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9.1 fifo description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 9.2 fifo registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 9.2.1 control register 5 (0x24) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 9.2.2 fifo control register (0x2e) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 9.2.3 fifo source register (0x2f) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 9.3 fifo modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 9.3.1 bypass mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 9.3.2 fifo mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 9.3.3 stream mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 9.3.4 stream-to-fifo mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 9.4 watermark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 9.5 retrieve data from fifo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
contents AN3308 4/52 doc id 18198 rev 1 10 auxiliary adc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 10.1 temperature sensor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 11 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
AN3308 list of tables doc id 18198 rev 1 5/52 list of tables table 1. registers table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 table 2. operating mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 table 3. data rate configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 table 4. power consumption (ma) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 table 5. switch mode timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 table 6. output data registers content vs. acceleration (fs = 2 g) . . . . . . . . . . . . . . . . . . . . . . . . . 14 table 7. high-pass filter mode configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 table 8. low power mode - high-pass filter cut-off frequency [hz]. . . . . . . . . . . . . . . . . . . . . . . . . . 16 table 9. reference mode lsb value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 table 10. ctrl_reg3 register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 table 11. ctrl_reg3 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 table 12. ctrl_reg6 register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 table 13. ctrl_reg6 register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 table 14. interrupt mode configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 table 15. duration lsb value in normal mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 0 table 16. threshold lsb value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 table 17. int1_src register in 6d position. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 table 18. tap_cfg register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 table 19. tap_cfg description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 table 20. truth table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 table 21. tap_src register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 table 22. tap_src description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 table 23. tap_ths register. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 table 24. tap_src description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 table 25. time_limit register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 table 26. time_limit register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 table 27. time_latency register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 table 28. time_latency description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 table 29. time_window description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 table 30. time_latency description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 table 31. ctrl_reg3 register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 table 32. ctrl_reg3 description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 table 33. fifo buffer full representation (32nd sample set stored). . . . . . . . . . . . . . . . . . . . . . . . . 39 table 34. fifo overrun representation (33rd sample set stored and 1st sample discarded) . . . . . 40 table 35. fifo enable bit in ctrl_reg5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 table 36. fifo_ctrl_reg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 table 37. fifo_src_reg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 table 38. fifo_src_reg behavior assuming fth[4:0] = 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 table 39. ctrl_reg3 (0x22) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 table 40. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
list of figures AN3308 6/52 doc id 18198 rev 1 list of figures figure 1. data ready signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 2. high-pass filter connections block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 3. hp_filter_reset readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 6 figure 4. reference mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 figure 5. autoreset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 figure 6. interrupt signals and interrupt pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 figure 7. free-fall, wake-up interrupt generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 figure 8. ff_wu_cfg high and low. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 figure 9. inertial wake-up interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 figure 10. free-fall interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 11. zh, zl, yh, yl, xh, and xl behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 7 figure 12. 6d movement vs. 6d position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 figure 13. 6d recognized positions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 figure 14. single click event with non latched interrupt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 figure 15. single and double click recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 figure 16. double click recognition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 figure 17. short timelimit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 figure 18. long timelimit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 figure 19. short latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 figure 20. long latency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 figure 21. short window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 figure 22. long window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 figure 23. fifo_en connection block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1 figure 24. fifo mode behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 figure 25. stream mode fast reading behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 figure 26. stream mode slow reading behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 5 figure 27. stream mode slow reading zoom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 figure 28. stream-to-fifo mode: interrupt not latched . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 figure 29. stream-to-fifo mode: interrupt latched . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 7 figure 30. watermark behavior - fth[4:0] = 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 figure 31. fifo reading diagram - fth[4:0] = 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 9
AN3308 registers table doc id 18198 rev 1 7/52 1 registers table table 1. registers table register name address bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 status_reg_aux 07h 321or 3or 2or 1or 321da 3da 2da 1da out_adc1_l 08h a1d7 a1d6 a1d5 a1d4 a1d3 a1d2 a1d1 a1d0 out_adc1_h 09h a1d15 a1d14 a1d13 a1d12 a1d11 a1d10 a1d9 a1d8 out_adc2_l 0ah a2d7 a2d6 a2d5 a2d4 a2d3 a2d2 a2d1 a2d0 out_adc2_h 0bh a2d15 a2d14 a2d13 a2d12 a2d11 a2d10 a2d9 a2d8 out_adc3_l 0ch a3d7 a3d6 a3d5 a3d4 a3d3 a3d2 a3d1 a3d0 out_adc3_h 0dh 3a3d15 c2 a3d13 a3d12 a3d11 a3d10 a3d9 a3d8 int_counter_reg0ehc7 c6c5c4c3c2 c1 c0 who_am_i 0fh0 01100 1 1 temp_cfg_reg 1fh adc_pd temp_en 0 0 0 0 0 0 ctrl_reg1 20h odr3 odr2 odr1 odr0 lpen zen yen xen ctrl_reg2 21h hpm1 hpm0 hpcf2 hpcf1 fds hpclick hpis2 hpis1 ctrl_reg3 22h i1_click i1_aoi1 0 i1_drdy1 i1_drdy2 i1_wtm i1_overrun - ctrl_reg4 23h bdu ble fs1 fs0 hr st1 st0 sim ctrl_reg5 24h boot fifo_en - - lir_int1 d4d_int1 0 0 ctrl_reg6 25h i2_clicken i2_int1 0 boot_i1 0 - h_lactive - reference 26h ref7 ref6 ref5 ref4 ref3 ref2 ref1 ref0 status_reg2 27h zyxor zor yor xor zyxda zda yda xda out_x_l 28h xd7 xd6 xd5 xd4 xd3 xd2 xd1 xd0 out_x_h 29h xd15 xd14 xd13 xd12 xd11 xd10 xd9 xd8 out_y_l 2ah yd7 yd6 yd5 yd4 yd3 yd2 yd1 yd0 out_y_h 2bh yd15 yd14 yd13 yd12 yd11 yd10 yd9 yd8
registers table AN3308 8/52 doc id 18198 rev 1 out_z_l 2ch zd7 zd6 zd5 zd4 zd3 zd2 zd1 zd0 out_z_h 2dh zd15 zd14 zd13 zd12 zd11 zd10 zd9 zd8 fifo_ctrl_reg 2e fm1 fm0 tr fth4 fth3 fth2 fth1 fth0 fifo_src_reg 2f wtm ovrn_fif o - fss4 fss3 fss2 fss1 fss0 int1_cfg 30h aoi 6d zhie zlie yhie ylie xhie xlie int1_src 31h - ia zh zl yh yl xh xl int1_ths 32h 0 ths6 ths5 ths4 ths3 ths2 ths1 ths0 int1_duration 33h 0 d6 d5 d4 d3 d2 d1 d0 click_cfg 38h - zd zs yd ys xd xs click_src 39h - ia dclick sclick sign z y x click_ths 3ah - ths6 ths5 ths4 ths3 ths2 ths1 ths0 time_limit 3bh - tli6 tli5 tli4 tli3 tli2 tli1 tli0 time_latency 3ch tla7 tla6 tla5 tla4 tla3 tla2 tla1 tla0 time_window 3dh tw7 tw6 tw5 tw4 tw3 tw2 tw1 tw0 act_ths 3eh - aths6 aths5 aths4 aths3 aths2 aths1 aths0 inact_dur 3fh adur7 adur6 adur5 adur4 adur3 adur2 adur1 adur0 table 1. registers table (continued) register name address bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
AN3308 operating modes doc id 18198 rev 1 9/52 2 operating modes the lis3dh provides three different operating modes, respectively reported as power-down mode, normal mode, and low power mode. while normal mode guarantees higher resolution, low power mode further reduces the current consumption. after power supply is applied, the lis3dh performs a 5 ms boot procedure to load the trimming parameter. after the boot is completed, the device is automatically configured in power-down mode. referring to the lis3dh datasheet, output data rate (odr) and low power enable (lpen) bits of ctrl_reg1 and hr bits of ctrl_reg4 are used to select the operating modes (power-down mode, normal mode and low power mode) and output data rate ( ta b l e 2 and ta bl e 3 ). ta bl e 4 shows the typical values of the power consumption for the different operating modes. table 2. operating mode selection operating mode ctrl_reg1[3] (lpen bit) ctrl_reg4[3] (hr bit) bw [hz] turn-on time [ms] low power mode 1 0 odr/2 1 normal mode 0 1 odr/9 7/odr table 3. data rate configuration odr3 odr2 odr1 odr0 power mode selection 0000 power-down mode 0001 normal/low power mode (1 hz) 0010 normal/low power mode (10 hz) 0011 normal/low power mode (25 hz) 0100 normal/low power mode (50 hz) 0101 normal/low power mode (100 hz) 0110 normal/low power mode (200 hz) 0111 normal/low power mode (400 hz) 1000 low power mode (1.5 khz) 1001normal (1. 250 khz)/low power mode (5 khz) table 4. power consumption ( a) odr(hz) normal mode ( a) low power mode ( a) power-down 0.4 0.4 12 2
operating modes AN3308 10/52 doc id 18198 rev 1 2.1 power-down mode when the device is in power-down mode, almost all internal blocks of the device are switched off to minimize power consumption. digital interfaces (i 2 c and spi) are still active to allow communication with the device. the configuration registers content is preserved and output data registers are not updated, therefore keeping the last data sampled in memory before going into power-down mode. 2.2 normal mode in normal mode, data are generated at the data rate (odr) selected through the dr bits and for the axis enabled through zen, yen, and xen bits of ctrl_reg1. data generated for a disabled axis is 00h. data interrupt generation is active and configured through the int1_cfg register. 2.3 low power mode while normal mode guarantees higher resolution, low power mode further reduces the current consumption. in low power mode, data are generated at the data rate (odr) selected through the dr bits and for the axis enabled through the zen, yen, and xen bits of ctrl_reg1. data generated for a disabled axis is 00h. data interrupt generation is active and configured through the int1_cfg register. 10 4 3 25 6 4 50 11 6 100 20 10 200 38 18 400 73 36 1250 185 - 1600 - 99 5000 - 184 table 4. power consumption ( a) (continued) odr(hz) normal mode ( a) low power mode ( a)
AN3308 operating modes doc id 18198 rev 1 11/52 2.4 switch mode timing switch mode time is shown in ta bl e 1 . table 5. switch mode timing starting mode target mode turn on time - typ (ms) power-down low power 2/odr power-down normal 7/odr normal power-down 0 low power power-down 0 low power normal 7/odr normal low power 2/odr
startup sequence AN3308 12/52 doc id 18198 rev 1 3 startup sequence once the device is powered-up, it automatically downloads the calibration coefficients from the embedded flash to the internal registers. when the boot procedure is completed, i.e. after approximately 5 milliseconds, the device automatically enters power-down mode. to turn on the device and gather acceleration data, it is necessary to select one of the operating modes through ctrl_reg1 and to enable at least one of the axes. the following general purpose sequence can be used to configure the device: 3.1 reading acceleration data 3.1.1 using the status register the device is provided with a status_reg which should be polled to check when a new set of data is available. the reading procedure should be the following: 1. write ctrl_reg1 2. write ctrl_reg2 3. write ctrl_reg3 4. write ctrl_reg4 5. write ctrl_reg5 6. write ctrl_reg6 7. write reference 8. write int1_ths 9. write int1_dur 10. write int1_cfg 11. write ctrl_reg5 1. read status_reg 2. if status_reg(3) = 0 then go to 1 3. if status_reg(7) = 1 then some data have been overwritten 4. read outx_l 5. read outx_h 6. read outy_l 7. read outy_h 8. read outz_l 9. read outz_h 10. data processing 11. go to 1
AN3308 startup sequence doc id 18198 rev 1 13/52 the check performed at step 3 allows to understand whether the reading rate is adequate compared to the data production rate. in case one or more acceleration samples have been overwritten by new data, because of a too slow reading rate, the zyxor bit of status_reg is set to 1. the overrun bits are automatically cleared when all the data present inside the device have been read and new data have not been produced in the meantime. 3.1.2 using the dat a-ready (dry) signal the device may be configured to have one hw signal to determinate when a new set of measurement data is available for reading. this signal is represented by the xyzda bit of status_reg. the signal can be driven to int1 pin by setting the i1_drdy1 bit of ctrl_reg3 to 1 and its polarity set to active-low or active-high through the h_lactive bit of ctrl_reg6. the data-ready signal rises to 1 when a new set of acceleration data has been generated and it is available for reading.the interrupt is reset when the higher part of the data of all the enabled channels has been read (29h, 2bh, 2dh). figure 1. data ready signal 3.1.3 using the block dat a update (bdu) feature if the reading of the acceleration data is particularly slow and cannot be synchronized (or it is not required) with either the xyzda bit present inside the status_reg or with the rdy signal, it is strongly recommended to set the bdu (block data update) bit in ctrl_reg4 to 1. this feature avoids the reading of values (most significant and least significant parts of the acceleration data) related to different samples. in particular, when the bdu is activated, the data registers related to each channel always contain the most recent acceleration data produced by the device, but, in case the reading of a given pair (i.e. out_x_h and out_x_l, out_y_h and out-y_l, out_z_h and out_z_l) is initiated, the refresh for that pair is blocked until both msb and lsb parts of the data are read. note: bdu only guarantees that out_x(y, z)_l and out_x(x,z)_h have been sampled at the same moment. for example, if the reading speed is too low, it may read x and y sampled at t1 and z sampled at t2. ".w 2$9 $!4!2%!$  .   e l p m a 3  l e c c ! .   e l p m a 3  l e c c ! ! 4 ! $ , % # # ! 89: 89:
startup sequence AN3308 14/52 doc id 18198 rev 1 3.2 understanding acceleration data the measured acceleration data are sent to outx_h, outx_l, outy_h, outy_l, outz_h, and outz_l registers. these registers contain, respectively, the most significant part and the least significant part of the acceleration signals acting on the x, y, and z axes. the complete acceleration data for the x (y, z) channel is given by the concatenation outx_h & outx_l (outy_h & outy_l, outz_h & outz_l) and it is expressed as a 2?s complement number. 3.2.1 data alignment acceleration data are represented as 16-bit numbers and are left justified. 3.2.2 big-little endian selection the lis3dh allows to swap the content of the lower and the upper part of the acceleration registers (i.e. outx_h with outx_l), to be compliant with both little-endian and big-endian data representations. ?little endian? means that the low-order byte of the number is stored in memory at the lowest address, and the high-order byte at the highest address. (the little end comes first). this mode corresponds to bit ble in ctrl_reg4 reset to 0 (default configuration). on the contrary, ?big endian? means that the high-order byte of the number is stored in memory at the lowest address, and the low-order byte at the highest address. 3.2.3 example of acceleration data ta bl e 6 provides a few basic examples of the data that is read in the data-registers when the device is subject to a given acceleration. the values listed in the table are given under the hypothesis of perfect device calibration (i.e. no offset, no gain error,....) and practically show the effect of the ble bit. table 6. output data registers content vs. acceleration (fs = 2 g ) acceleration values ble = 0 ble = 1 register address 28h 29h 28h 29h 0 g 00h 00h 00h 00h 350 mg e0h 15h 15h e0h 1 g 00h 04h 04h 00h -350 mg 20h eah eah 20h -1g 00h c0h c0h 00h
AN3308 high-pass filter doc id 18198 rev 1 15/52 4 high-pass filter the lis3dh provides an embedd ed high-pass filtering capabilit y to easily delete the dc component of the measured acceleration. as shown in figure 2 , through fds, hpen1, and hpen2 bits of ctrl_reg2 configuration, it is possible to independently apply the filter on the output data and/or on the interrupts data. this means that it is possible, i.e., to get filtered data while interrupt generation works on unfiltered data. figure 2. high-pass filter connections block diagram 4.1 filter configuration referring to ta bl e 7 , two operating modes are possible for the high-pass filter: the bandwidth of the high-pass filter depends on the selected odr and on the settings of hpcfx bits of ctrl_reg2. the high-pass filter cut-off frequencies (f t ) are shown in ta bl e 8 . !-v +3)lowhu ,qwhuuxsw &75/b5(* +3,6  &75/b5(* )'6    2xwsxwuhjv 65&uhj 6rxufh $'& table 7. high-pass filter mode configuration hpm1 hpm0 high-pass filter mode 0 0 normal mode (reset reading hp_reset_filter) 0 1 reference signal for filtering 10 normal mode 1 1 autoreset on interrupt event
high-pass filter AN3308 16/52 doc id 18198 rev 1 4.1.1 normal mode in this configuration the high-pass filter can be reset reading the reference register, instantly deleting the dc component of the acceleration. figure 3. hp_filter_reset readings 4.1.2 reference mode in this configuration the output data is ca lculated as the difference between the input acceleration and the content of the reference register. this register is in 2? complement representation and the value of 1 lsb of these 7-bit registers depends on the selected full scale ( ta bl e 9 ). table 8. low power mode - high-pass filter cut-off frequency [hz] hpc f t [hz] @ 1hz f t [hz] @ 10hz f t [hz] @ 25hz f t [hz] @ 50hz f t [hz] @ 100hz f t [hz] @ 200hz f t [hz] @ 400hz f t [hz] @ 1.6 khz f t [hz] @ 5 khz 00 0.02 0.2 0.5 1 2 4 8 32 100 01 0.008 0.08 0.2 0.5 1 2 4 16 50 10 0.004 0.04 0.1 0.2 0.5 1 2 8 25 11 0.002 0.02 0.05 0.1 0.2 0.5 1 4 12 !-v &iltered$ata (0?&),4%2?2%3% 4 table 9. reference mode lsb value full scale reference mode lsb value (mg) 2~16 4~31 8~63
AN3308 high-pass filter doc id 18198 rev 1 17/52 figure 4. reference mode 4.1.3 autoreset in this configuration the filter is automatica lly reset when the configured interrupt event occurs. hp_reset is, however, used to set the filter instantaneously. note: xyz dataset used to reset the filter is the one after the interrupt. figure 5. autoreset ".w )nput!cceleration &iltered$ata 2%&%2%.#%enable 2%&%2%.#% !-v &iltered$ata 2%&%2%.#%enable
interrupt generation AN3308 18/52 doc id 18198 rev 1 5 interrupt generation the lis3dh interrupts signal can behave as free-fall, wake-up, 6d and 4d orientation detection, and click detection. those signals can be driven to the two interrupt pins (int1 and int2). 5.1 interrupt pin configuration the device is provided with two pins which can be activated to generate either the data- ready or the interrupt signals. the functionality of the pins is selected through ctrl_reg3(22h) and ctrl_reg6(25h). refer to ta b l e 1 0 and ta b l e 1 1 and to the block diagram given in figure 6 . table 10. ctrl_reg3 register i1_click i1_int1 0 i1_drdy1 - i1_wtm i1_overrun - table 11. ctrl_reg3 description i1_click click interrupt on int1. default value 0. (0: disable; 1: enable) i1_int1 interrupt generator 1 on int1 pin. default value 0. (0: disable; 1: enable) i1_drdy1 drdy1 interrupt on int1. default value 0. (0: disable; 1: enable) i1_wtm fifo watermark interrupt on int1. default value 0. (0: disable; 1: enable) i1_overrun fifo overrun interrupt on int1. default value 0. (0: disable; 1: enable) table 12. ctrl_reg6 register i2_clicken i2_int1 0 boot_i2 0 - h_lactive - table 13. ctrl_reg6 register i2_clicken click interrupt on int2. default value 0. (0: disable; 1: enable) i2_int2 interrupt generator 1 on int2 pin. default value 0. (0: disable; 1: enable) boot_i2 boot status on int2. default value 0. (0: disable; 1: enable) hl_active 0: interrupt active high; 1: interrupt active low
AN3308 interrupt generation doc id 18198 rev 1 19/52 figure 6. interrupt signals and interrupt pins !-v ,17sdg &75/b5(*  &/,&. &75/b5(*  $2, &75/b5(*  $2, &75/b5(*  '5'< &75/b5(*  '5'< &75/b5(*  :70 &75/b5(*  29(5581 ,17sdg &75/b5(*  &/,&. &75/b5(*  $2, &75/b5(*  %227     &75/b5(*  &75/b5(* 
inertial interrupt AN3308 20/52 doc id 18198 rev 1 6 inertial interrupt the lis3dh can provide two inertial interrupt signals and offers several possibilities to personalize those signals. the registers involved in the interrupt generation behavior are int1_cfg, int1_ths and int1_duration. whenever an interrupt condition is verified the interrupt signal is generated and by reading the int1_src register it is possible to understand which condition happened. 6.1 duration the content of the duration registers sets the minimum duration of the interrupt event to be recognized. duration steps and maximum values depend on the odr chosen. duration time is measured in n/odr, where n is the content of the duration register and odr is 50, 100, 400, 1000 hz. table 14. interrupt mode configuration aoi 6d interrupt mode 0 0 or combination of interrupt events 0 1 6 direction move ment recognition 1 0 and combination of interrupt events 1 1 6 direction position recognition table 15. duration lsb value in normal mode odr (hz) duration lsb value (ms) 1 1000 10 100 25 40 50 20 100 10 200 5 400 2.5 1000 1 1344 0.744 1620 0.617
AN3308 inertial interrupt doc id 18198 rev 1 21/52 6.2 threshold threshold registers define the reference accelerations used by interrupt generation circuitry. the value of 1 lsb of these 7-bit registers depends on the selected full scale ( ta bl e 1 6 ). 6.3 free-fall and wake-up interrupts the lis3dh interrupts signal can behave as free-fall and wake-up. whenever an interrupt condition is verified, the interrupt signal is generated and by reading the int1_src register it is possible to understand which condition happened. the free-fall signal (ff) and wake-up signal (wu) interrupt generation block is represented in figure 7 . the ff or wu interrupt generation is selected through the aoi bit in the int1_cfg register. if the aoi bit is ?0?, signals coming from comparators for the axis enabled through the int1_cfg register are put in logical or. in this case, interrupt is generated when at least one of the enabled axes exceeds the threshold written in module in int1_ths registers. otherwise, if the aoi bit is ?1?, signals coming from comparators enter a ?nand? port. in this case an interrupt signal is generated only if all the enabled axes are passing the threshold written in the int1_ths register. lir1 bits of ctrl_reg3 allow to decide if the interrupt request must be latched or not. if lir1 bit is ?0? (default value), the interrupt signal goes high when the interrupt condition is satisfied and returns to low immediately if the interrupt condition is no longer verified. otherwise, if the lir1 bit is ?1?, whenever an interrupt condition is applied the interrupt signal remains high even if the condition returns to a non-interrupt status until a reading to the int1_src register is performed. the zhie, zlie, yhie, ylie, xhie, and hlie bits of the int1_cfg register allow to decide on which axis the interrupt decision must be performed and on which direction the threshold must be passed to generate the interrupt request. table 16. threshold lsb value full scale threshold lsb value (mg) 2~16 4~31 8~63 16 ~125
inertial interrupt AN3308 22/52 doc id 18198 rev 1 figure 7. free-fall, wake-up interrupt generator the threshold module which is used by the system to detect any free-fall or inertial wake-up event is defined by the int1_ths register. the threshold value is expressed over 7 bits as an unsigned number and is symmetrical around the zero-g level. xh (yh, zh) is true when the unsigned acceleration value of the x (y, z) channel is higher than int1_ths. similarly, xl (yl, zl) low is true when the unsigned acceleration value of the x (y, z) channel is lower than int1_ths. refer to figure 8 for more details. figure 8. ff_wu_cfg high and low ".w 4(3reg \b\a \b\a !ccel?8 8(% 8,% 75 &&   ).4x?#&'!/) \b\a \b\a 9(% 9,% \b\a \b\a :(% :,% !ccel?9 !ccel?: !-v &ull3cale &ull3cale glevel 4hres holdmodule 4hresholdmodule 89 : high 89 : high 89 : low 0ositive .egative acceleration acceleration
AN3308 inertial interrupt doc id 18198 rev 1 23/52 6.3.1 inertial wake-up wake-up interrupt refers to a specific configuration of the int1_ctrl register that allows interrupt generation when the acceleration on the configured axis exceeds a defined threshold ( figure 9 ). figure 9. inertial wake-up interrupt 6.3.2 hp filter bypassed this paragraph provides a basic algorithm which shows the practical use of the inertial wake-up feature. in particular, with the code below, the device is configured to recognize when the absolute acceleration along either the x or y axis exceeds a preset threshold (250 mg used in the example). the event which triggers the interrupt is latched inside the device and its occurrence is signalled through the use of the int1 pin. !-v g 7!+%50 4(2%3(/,$ 7+0)nterrupt g 7!+%50 4(2%3(/,$ 7+0)nterrupt 1 write a7h into ctrl_reg1 // turn on the sensor and enable x, y, and z // odr = 100 hz 2 write 00h into ctrl_reg2 // high-pass filter disabled 3 write 40h into ctrl_reg3 // interrupt driven to int1 pad 4 write 00h into ctrl_reg4 // fs = 2 g 5 write 08h into ctrl_r eg5 // interrupt latched 6 write10h into int1_ths // threshold = 250 mg 7 write 00h into int1_duration // duration = 0 8 write 0ah into int1_cfg // enable xh and yh interrupt generation 9 poll int1 pad; if int1=0 then go to 8 // poll rdy/int pin waiting for the // wake-up event 10 read int1_src // return the event that has triggered the // interrupt 11 (wake-up event has occurred; insert your code here) // event handling 12 go to 8
inertial interrupt AN3308 24/52 doc id 18198 rev 1 6.3.3 using the hp filter the code provided below gives a basic routine which shows the practical use of the inertial wake-up feature performed on high-pass filtered data. in particular the device is configured to recognize when the high-frequency component of the acceleration applied along either the x, y, or z axis exceeds a preset threshold (250 mg used in the example). the event which triggers the interrupt is latched inside the device and its occurrence is signalled through the use of the int1 pin. at step 8, a dummy reading at the hp_filte r_reset register is performed to set the current/reference acceleration/tilt state against which the device performed the threshold comparison. this reading may be performed any time it is required to set the orientation/tilt of the device as a reference state without waiting for the filter to settle. 1 write a7h into ctrl_reg1 // turn on the sensor, enable x, y, and z // odr = 100 hz 2 write 09h into ctrl_reg2 // high-pass filter enabled on data and interrupt1 3 write 40h into ctrl_reg3 // interrupt driven to int1 pad 4 write 00h into ctrl_reg4 // fs = 2 g 5 write 08h into ctrl_reg5 // interrupt latched 6 write10h into int1_ths // threshold = 250 mg 7 write 00h into int1_duration // duration = 0 8 read hp_filter_reset // dummy read to force the hp filter to // current acceleration value // (i.e. set reference acceleration/tilt value) 9 write 2ah into int1_cfg // configure desired wake-up event 10 poll int1 pad; if int1 = 0 then go to 9 // poll int1 pin waiting for the // wake-up event 11 (wake-up event has occurred; insert your code here) // event handling 12 read int1_src // return the event that has triggered the // interrupt and clear interrupt 13 (insert your code here) // event handling 14 go to 9
AN3308 inertial interrupt doc id 18198 rev 1 25/52 6.4 free-fall detection free-fall detection refers to a specific config uration of int1_ctrl registers that allows to recognize when the device is free falling: th e acceleration measure along all the axes goes to zero. in a real case a ?free-fall zone? is defined around the zero-g level where all the accelerations are small enough to generate the interrupt ( figure 10 ). figure 10. free-fall interrupt this paragraph provides the basics for the use of the free-fall detection feature. in particular, the sw routine that configures the device to detect free-fall events and to signal them is the following: 1 write a7h into ctrl_reg1 // turn on the sensor, enable x, y, and z // odr = 100 hz 2 write 00h into ctrl_reg2 // high-pass filter disabled 3 write 40h into ctrl_reg3 // in terrupt driven to int1 pad 4 write 00h into ctrl_reg4 // fs = 2 g 5 write 08h into ctrl_reg5 // interrupt latched 6 write 16h into int1_ths // se t free-fall threshold = 350 mg 7 write 03h into int1_duration // set minimum event duration 8 write 95h into int1_cfg // configure free-fall recognition 9 poll int1 pad; if int1 = 0 then go to 10 // poll int1 pin waiting for the free-fall event 10 (free-fall event has occurred; insert your code here) // event handling 11 read int1_src register // clear interrupt request 12 go to 9 !-v g &2%%&!,, :/.% 8 9 : &&)nterrupt
inertial interrupt AN3308 26/52 doc id 18198 rev 1 the code sample exploits a threshold set at 350 mg for free-fall recognition and the event is notified by the hardware signa l int1. at step 7, the int1_dura tion register is configured like this to ignore events that are shorter than 3/dr = 3/100 ~= 30 msec in order to avoid false detections. once the free-fall event has occurred, a reading of the int1_src register clears the request and the device is ready to recognize other events.
AN3308 6d/4d orientation detection doc id 18198 rev 1 27/52 7 6d/4d orientation detection the lis3dh provides an advanced capability to de tect the orientation of the device in the space, enabling easy implementation of an energy saving procedure and automatic image rotation for handheld devices. 7.1 6d orientation detection the 6d orientation direction function can be enabled through aoi and 6d bits of the int1_cfg register. when configured for 6d function, the zh, zl, yh, yl, xh, and xl bits of int1_src give information about the value of the acceleration generating the interrupt when it is greater than the threshold, and about its sign. in more detail: zh (yh, xh) is 1 when the sensed acceleration is bigger than the threshold in the positive direction zl (yl, xl) is 1 when the sensed acceleration is bigger than the threshold in the negative direction. figure 11. zh, zl, yh, yl, xh, and xl behavior there are two possible configurations for the 6d direction function: 6d movement recognition: in this configuration the interrupt is generated when the device moves from a direction (known or unknown) to a different known direction. the interrupt is active only for 1/odr 6d position recognition: in this configuration the interrupt is generated when the device is stable in a known direction. the interrupt is active as long as position is maintained ( figure 12 , (a) and (b) ). referring to figure 12 , the 6d movement line shows the behavior of the interrupt when the device is configured for 6d movement recognition on the x and y axis (int1_cfg = 0x4ah), while the 6d position line shows the behavior of the interrupt when the device is configured for 6d position recognition on the x and y axis (int1_cfg = 0xcah). int1_ths is set to 0x21. referring to figure 13 , the device has been configured for 6d position function on x, y, and z axes. ta bl e 1 7 shows the content of the int1_src register for each position. !-v &ull3cale &ull3cale glevel 4hreshold 4hreshold 8( 9( :(  8,9, :,  0ositive .egative acceleration acceleration 8(9( :(  8,9, :, 
6d/4d orientation detection AN3308 28/52 doc id 18198 rev 1 figure 12. 6d movement vs. 6d position figure 13. 6d recognized positions !-v 8 9 : $0osition $-ovement a b !-v 8 9 : "ottom 8 9 : 8 9 : 8 9 : 8 9 : 8 9 : 8 9 : 8 9 : 8 9 : 9  8 : 8 9 : 4op 8 9 : 4op b  a  d c f  e 
AN3308 6d/4d orientation detection doc id 18198 rev 1 29/52 7.2 4d direction the 4d direction function is a subset of the 6d function especially defined to be implemented in handheld devices. it can be enabled by setting the d4d_int1 bit of ctrl_reg5 to 1 when the 6d bit on int1_cfg is set to 1. in this configuration, z axis position detection is disabled, therefore reducing position recognition to cases (a), (b), (c), and (d) of ta b l e 1 7 . table 17. int1_src register in 6d position case ia zh zl yh yl xh xl (a)1000100 (b)1000010 (c)1000001 (d)1001000 (e)1100000 (f)1010000
click and double click recognition AN3308 30/52 doc id 18198 rev 1 8 click and double click recognition the single click and double click recognition functions featured in the lis3dh help to create a man-machine interface with little software loading. the device can be configured to output an interrupt signal on a dedicated pin when tapped in any direction. if the sensor is exposed to a single input stimulus, it generates an interrupt request on inertial interrupt pin int1 and/or int2. a more advanced feature allows the generation of an interrupt request when a double input stimulus with programmable time between the two events is recognized, enabling a mouse button-like function. this function can be fully programmed by the user in terms of expected amplitude and timing of the stimuli by means of the dedicated set of registers described in section 8.3 . single and double click recognition works independently on the selected output data rate. 8.1 single click if the device is configured for single click event detection, an interrupt is generated when the input acceleration on the selected channel exceeds the programmed threshold, and returns below it within a time window defined by the timelimit register. if the lir bit of the tap_cfg register is not set, the interrupt is kept high for the duration of the latency window. if the lir bit is set, the interrupt is kept high until the tap_src register is read. figure 14. single click event with non latched interrupt in figure 14 (a) the click has been recognized, while in figure 14 (b) the click has not been recognized because the acceleration goes under the threshold after the timelimit has expired. (a) (b)
AN3308 click and double click recognition doc id 18198 rev 1 31/52 8.2 double click if the device is configured for double click event detection, an interrupt is generated when, after a first click, a second click is recognized. the recognition of the second click occurs only if the event satisfies the rules def ined by the latency and windows registers. in particular, after the first click has been re cognized, the second click detection procedure is delayed for an interval defined by the latency register. this means that after the first click has been recognized, the second click detection procedure starts only if the input acceleration exceeds the threshold after the latency window but before the window has expired ( figure 15 (a) ), or if the acceleration is still above the threshold after the latency has expired ( figure 16 (b) ). once the second click detection procedure is in itiated, the second clic k is recognized with the same rule as the first: the acceleration must return below the threshold before the timelimit has expired. it is important to appropriately define the latency window to avoid unwanted clicks due to spurious bouncing of the input signal. figure 15. single and double click recognition figure 15 illustrates a single click event (a) and a do uble click event (b). the device is able to distinguish between (a) and (b) by changing the settings of the tap_cfg register from single to double click recognition. (a) (b)
click and double click recognition AN3308 32/52 doc id 18198 rev 1 figure 16. double click recognition in figure 16 (a) the double click event has been correctly recognized, while in figure 16 (b) the interrupt has not been generated because the input acceleration exceeds the threshold after the window interval has expired. 8.3 register description 8.3.1 tap_cfg (38h) (a) (b) table 18. tap_cfg register - - zd zs yd ys xd xs table 19. tap_cfg description zd enable interrupt double tap-tap on z axis. default value: 0 (0: disable interrupt request; 1: enable inte rrupt request on measured accel. value higher than preset threshold) zs enable interrupt single tap-tap on z axis. default value: 0 (0: disable interrupt request; 1: enable inte rrupt request on measured accel. value higher than preset threshold) yd enable interrupt double tap-tap on y axis. default value: 0 (0: disable interrupt request; 1: enable inte rrupt request on measured accel. value higher than preset threshold) ys enable interrupt single tap-tap on y axis. default value: 0 (0: disable interrupt request; 1: enable inte rrupt request on measured accel. value higher than preset threshold)
AN3308 click and double click recognition doc id 18198 rev 1 33/52 8.3.2 tap_src (39h) xd enable interrupt double tap-tap on x axis. default value: 0 (0: disable interrupt request; 1: enable inte rrupt request on measured accel. value higher than preset threshold) xs enable interrupt single tap-tap on x axis. default value: 0 (0: disable interrupt request; 1: enable inte rrupt request on measured accel. value higher than preset threshold) table 20. truth table dz / dy / dx sz / y / x click output 000 01single 1 0 double 1 1 single or double table 19. tap_cfg description (continued) table 21. tap_src register - ia dtap stap sign z y x table 22. tap_src description -- ia interrupt active. default value: 0 (0: no interrupt has been generated; 1: one or more interrupts have been generated) dtap double tap-tap enable. default value: 0 (0: double tap-tap detection disable, 1: double tap-tap detection enable) stap single tap-tap enable. default value: 0 (0: single tap-tap detection disable, 1: single tap-tap detection enable) sign tap-tap sign. 0: positive de tection, 1: negative detection z z tap-tap detection. default value: 0 (0: no interrupt, 1: z high event has occurred) y y tap-tap detection. default value: 0 (0: no interrupt, 1: y high event has occurred) x x tap-tap detection. default value: 0 (0: no interrupt, 1: x high event has occurred)
click and double click recognition AN3308 34/52 doc id 18198 rev 1 8.3.3 tap_ths (3ah) 1 lsb = full scale/128. ths6 through ths0 define the threshold which is used by the system to start the click detection procedure. the threshold value is expressed over 6 bits as an unsigned number. 8.3.4 time_limit (3bh) 1 lsb = 1/odr. tli7 through tli0 define the maximum time interval that can elapse between the start of the click detection procedure (the acceleration on the selected channel exceeds the programmed threshold) and when the acceleration goes back below the threshold. 8.3.5 time_latency (3ch) 1 lsb = 1/odr. tla7 through tla0 define the time interval that starts after the first click detection where the click detection procedure is disabled, in cases where the device is configured for double click detection. table 23. tap_ths register - ths6 ths5 ths4 ths3 ths2 ths1 ths0 table 24. tap_src description ths6-ths0 tap-tap threshold. default value: 000 0000 table 25. time_limit register - tli6 tli5 tli4 tli3 tli2 tli1 tli0 table 26. time_limit register tli7-tli0 tap-tap time limit. default value: 000 0000 table 27. time_latency register tla7 tla6 tla5 tla4 tla3 tla2 tla1 tla0 table 28. time_latency description tla7-tla0 tap-tap time latency. default value: 000 0000
AN3308 click and double click recognition doc id 18198 rev 1 35/52 8.3.6 time window (3dh) 1 lsb = 1/odr. tw7 throughtw0 define the maximum interval of time that can elapse after the end of the latency interval in which the click detection procedure can start, in cases where the device is configured for double click detection. 8.3.7 ctrl_reg3 [interrupt ctrl register] (22h) 8.4 examples the following figures show the click interrupt generation in different conditions. the illustrations have been captured on a pc runni ng the demonstration kit gui interface with odr set to 400 hz and full scale to 4 g. the content of the lis3dh registers have been modified via the dedicated panel of the software interface that allows the user to evaluate all the different settings and features of the click embedded function. in the following examples, only the x axis has been enabled for the click interrupt generation. table 29. time_window description tw7 tw6 tw5 tw4 tw3 tw2 tw1 tw0 table 30. time_latency description tw7-tw0 tap-tap time window table 31. ctrl_reg3 register i1_tap i1_int1 - i1_drdy1 i1_drdy2 i1_wtm i1_overrun - table 32. ctrl_reg3 description i1_tap tap interrupt on int1. default value 0. (0: disable; 1: enable) i1_int1 interrupt generator 1 on int1 pin. default value 0. (0: disable; 1: enable) i1_drdy1 drdy1 interrupt on int1. default value 0. (0: disable; 1: enable) i1_drdy2 drdy2 interrupt on int1. default value 0. (0: disable; 1: enable) i1_wtm fifo watermark interrupt on int1. default value 0. (0: disable; 1: enable) i1_overrun fifo overrun interrupt on int1. default value 0. (0: disable; 1: enable)
click and double click recognition AN3308 36/52 doc id 18198 rev 1 8.4.1 playing with tap_timelimit figure 17 shows an acquisition carried out with tap_timelimit = 01h (2.5 ms). with this setting, the single click recognition window is short and often the acceleration does not return below the threshold in time. in figure 18 an acquisition done with tap_timelimit = 33h (127 ms) is shown. with this setting the single click recognition window is longer, and it is easier for the event to be recognized. figure 17. short timelimit figure 18. long timelimit
AN3308 click and double click recognition doc id 18198 rev 1 37/52 8.4.2 playing with tap_latency figure 19 illustrates an acquisition done with tap_ latency =15h (52 ms). with this setting the device recognizes nearly every acceleration peak as a click. in figure 20 an acquisition carried out with tap_latency = ffh (637 ms) is displayed. with this setting the device recognizes one peak in every two as a click. figure 19. short latency figure 20. long latency
click and double click recognition AN3308 38/52 doc id 18198 rev 1 8.4.3 playing with tap_window in cases of double click recognition, the tap_latency + tap_window defines the maximum distance between two consecutive clicks to be recognized as a double click event. by fixing the latency to avoid spurious bouncing of the signal, it is possible to play with the tap_window as with the ?double click speed? settings of the mouse properties on the pc. figure 21 shows an acquisition done with tap_window = 42h (1065 ms). with this setting the two consecutive peaks of acceleration are too far apart and the second one occurs outside of the window. in figure 22 an acquisition carried out with tap_window = ffh (637 ms) is shown. with this setting the device correctly generates the double click interrupt after the second acceleration peak. figure 21. short window figure 22. long window
AN3308 first in first out (fifo) buffer doc id 18198 rev 1 39/52 9 first in first out (fifo) buffer in order to decrease the host processor interaction and facilitate post processing data for events recognition, lis3dh embeds a first in first out buffer (fifo) for each of the three output channels, x, y, and z. fifo use allows a consistent power saving for the system, it can wake-up only when needed and burst the significant data out from the fifo. the fifo buffer can work according to four different modes that guarantee a high-level of flexibility during application development: bypass mode, fifo mode, stream mode, and stream-to-fifo mode. the programmable watermark level and fifo overrun event can be enabled to generate dedicated interrupts on the int1 pin. 9.1 fifo description the fifo buffer is able to store up to 32 acceleration samples of 10 bits for each channel; data are stored in the 16-bit 2?s complement left justified representation. the data samples set consists of 6 bytes (xl, xh, yl, yh, zl, and zh) and they are released to the fifo at the selected output data rate (odr). the new sample set is placed in the first empty fifo slot until the buffer is full, therefore, the oldest value is overwritten. table 33. fifo buffer full representation (32 nd sample set stored) output registers 0x28h 0x29h 0x2ah 0x2bh 0x2ch 0x2dh xl(0) xh(0) yl(0) yh(0) zl(0) zh(0) fifo index fifo sample set fifo(0) xl(0) xh(0) yl(0) yh(0) zl(0) zh(0) fifo(1) xl(1) xh(1) yl(1) yh(1) zl(1) zh(1) fifo(2) xl(2) xh(2) yl(2) yh(2) zl(2) zh(2) fifo(3) xl(3) xh(3) yl(3) yh(3) zl(3) zh(3) ... ... ... ... ... ... ... ... ... ... ... ... ... ... fifo(30) xl(30) xh(30) yl(30) yh(30) zl(30) zh(30) fifo(31) xl(31) xh(31) yl(31) yh(31) zl(31) zh(31)
first in first out (fifo) buffer AN3308 40/52 doc id 18198 rev 1 ta bl e 3 3 represents the fifo full status when 32 samples are stored in the buffer while ta bl e 3 4 represents the next step when the 33 rd sample is inserted into fifo and the 1 st sample is overwritten. the new oldest sample set is made available in the output registers. when fifo is enabled and mode is different from bypass, the lis3dh output registers (28h to 2dh) always contain the oldest fifo sample set. 9.2 fifo registers the fifo buffer is managed by three different accelerometer registers, two of these allow to enable and configure the fifo behavior, the third provides information about the buffer status. 9.2.1 control r egister 5 (0x24) the fifo_en bit in ctrl_reg5 must be set to 1 in order to enable the internal first in first out buffer; while this bit is set, the accelerometer output registers (28h to 2dh) don?t contain the current acceleration value but they always contain the oldest value stored in fifo. table 34. fifo overrun representation (33 rd sample set stored and 1 st sample discarded) output registers 0x28h 0x29h 0x2ah 0x2bh 0x2ch 0x2dh xl(1) xh(1) yl(1) yh(1) zl(1) zh(1) fifo index sample set fifo(0) xl(1) xh(1) yl(1) yh(1) zl(1) zh(1) fifo(1) xl(2) xh(2) yl(2) yh(2) zl(2) zh(2) fifo(2) xl(3) xh(3) yl(3) yh(3) zl(3) zh(3) fifo(3) xl(4) xh(4) yl(4) yh(4) zl(4) zh(4) ... ... ... ... ... ... ... ... ... ... ... ... ... ... fifo(30) xl(31) xh(31) yl(31) yh(31) zl(31) zh(31) fifo(31) xl(32) xh(32) yl(32) yh(32) zl(32) zh(32) table 35. fifo enable bit in ctrl_reg5 b7 b6 b5 b4 b3 b2 b1 b0 xfifo_enxxxxxx
AN3308 first in first out (fifo) buffer doc id 18198 rev 1 41/52 figure 23. fifo_en connection block diagram 9.2.2 fifo control register (0x2e) this register is dedicated to fifo mode selection and watermark configuration. fm[1:0] bits are dedicated to define the fifo buffer behavior selection: 1. fm[1:0] = (0,0): bypass mode 2. fm[1:0] = (0,1): fifo mode 3. fm[1:0] = (1,0): stream mode 4. fm[1:0] = (1,1): stream-to-fifo mode the trigger used to activate stream-to-fifo mode is related to the ia bit value of the selected int1_src register and does not depend on the interrupt pin value and polarity. the trigger is generated also if the selected interrupt is not driven to an interrupt pin. fth[4:0] bits are intended to define the watermark level; when fifo content exceeds this value the wtm bit is set to ?1? in the fifo source register. !-v &)&/ "uffer !$# /utput2egisters   #42,?2%'&)&/?%. -easurement #hain &)&/ "uffer !$# /utput2egisters   #42,?2%'&)&/?%. table 36. fifo_ctrl_reg b7 b6 b5 b4 b3 b2 b1 b0 fm1 fm0 0 fth4 fth3 fth2 fth1 fth0
first in first out (fifo) buffer AN3308 42/52 doc id 18198 rev 1 9.2.3 fifo source register (0x2f) this register is updated at every odr and provides information about the fifo buffer status. wtm bit is set high when fifo content exceeds watermark level. ovrn bit is set high when fifo buffer is full, this means that the fifo buffer contains 32 unread samples. at the following odr a new sample set replaces the oldest fifo value. the ovrn bit is reset when th e first sample set has been read. empty flag is set high when all fifo samples have been read and fifo is empty. fss[4:0] field always contains the current number of unread samples stored in the fifo buffer. when fifo is enabled, this value increases at odr frequency until the buffer is full, whereas, it decreases every time that one sample set is retrieved from fifo. register content is updated synchronous to the fifo write and read operation. the watermark flag and fifo overrun event can be enabled to generate a dedicated interrupt on the int1 pin by configuring ctrl_reg3. i1_wtm bit drives watermark flag (wtm) on the int1 pin. i1_ovrn bit drives overrun event (ovrn) on the int1 pin. table 37. fifo_src_reg b7 b6 b5 b4 b3 b2 b1 b0 wtm ovrn empty fss4 fss3 fss2 fss1 fss0 table 38. fifo_src_reg behavior assuming fth[4:0] = 15 wtm ovrn empty fss[4:1] unread fifo samples timing 0 0 1 00000 0 t0 0 0 0 00001 1 t0 + 1/odr 0 0 0 00010 2 t0 + 2/odr ... ... ... ... ... ... 0 0 0 01111 15 t0 + 15/odr 1 0 0 10000 16 t0 + 16/odr ... ... ... ... ... ... 1 0 0 11110 30 t0 + 30/odr 1 0 0 11111 31 t0 + 31/odr 1 1 0 11111 32 t0 + 32/odr table 39. ctrl_reg3 (0x22) b7 b6 b5 b4 b3 b2 b1 b0 x x x x x i1_wtm i1_ovrn x
AN3308 first in first out (fifo) buffer doc id 18198 rev 1 43/52 if both bits are set to ?1?, the int1 pin status is the logical or combination of the two signals. 9.3 fifo modes the lis3dh fifo buffer can be configured to operate in four different modes selectable by the fm[1:0] field in fifo_ctrl_reg. available configurations ensure a high-level of flexibility and extend the numb er of functions usable in application development. bypass, fifo, stream, and stream-to-fifo modes are described in the following paragraphs. 9.3.1 bypass mode when bypass mode is enabled, fifo is not operational: buffer content is cleared, output registers (0x28 to 0x2d) are frozen at the last value loaded, and the fifo buffer remains empty until another mode is selected. follow these steps for bypass mode configuration: 1. turn on fifo by setting the fifo_en bit to ?1? in control register 5 (0x24). after this operation the fifo buffer is enabled but isn?t collecting data, output registers are frozen to the last samples set loaded. 2. activate bypass mode by setting the fn[1:0] field to ?00? in the fifo control register (0x2e). if this mode is enabled, fifo source register (0x2f) is forced equal to 0x20. bypass mode must be used in order to stop and reset the fifo buffer when a different mode is operating. note that placing the fifo buffer into bypass mode clears the whole buffer content. 9.3.2 fifo mode in fifo mode, the buffer cont inues filling until full (32 sample set stored,) then it stops collecting data and the fifo content remains unchanged until a different mode is selected. follow these steps for fifo mode configuration: 1. turn on fifo by setting the fifo_en bit to ?1? in control register 5 (0x24). after this operation the fifo buffer is enabled but isn?t collecting data, output registers are frozen to the last samples set loaded. 2. activate fifo mode by setting the fn[1:0] field to ?01? in the fifo control register (0x2e). by selecting this mode, fifo starts data collection and source register (0x2f) changes according to the number of samples stored. at the end of the procedure, the source register is set to 0xdf and the ovrn flag generates an interrupt if the i1_ovrn bit is selected in control register 5. data can be retrieved when ovrn is set to?1?, performing a 32 sample set reading from the output registers, data can be retrieved also on the wtm flag instead of ovrn if the application requires a lower num ber of samples. commun ication speed is not so important in fifo mode because data collection is stopped and there is no risk of overwriting acquired data. before restarting fifo mode, at the end of the reading procedure it is necessary to transit from bypass mode. a fifo mode application hint is reported below:
first in first out (fifo) buffer AN3308 44/52 doc id 18198 rev 1 1. set fifo_en = 1: enable fifo 2. set fn[1:0] = (0,1): enable fifo mode 3. wait ovrn or wtm interrupt 4. read data from accelerometer output registers 5. set fn[1:0] = (0,0): enable bypass mode 6. repeat from point 2 figure 24. fifo mode behavior if fifo mode is enabled, the buffer starts to co llect data and fill all th e 32 slots (from f0 to f31) at the selected output data rate. when the buffer is full, the ovrn bit goes up and data collection is permanently stopped; the user can decide to read fifo content at any time because it is maintained unchanged until bypass mode is selected. the reading procedure is composed of a 32 sample set of 6 bytes for a total of 192 bytes and retrieves data starting from the oldest sample stored in fifo (f0). the ovrn bit is reset when the first sample set has been read. the bypass mode setting resets fifo and allows the user to enable fifo mode again. 9.3.3 stream mode in stream mode fifo continues filling, when the buffer is full, the fifo in dex restarts from the beginning and older data is replaced by the current. the oldest values continue to be overwritten until a read operation makes free fifo slots available. host processor reading speed is most important in order to free slots faster than new data is made available. fm[1:0] bypass configuration is used to stop this mode. follow these steps for fifo mode configuration: 1. turn on fifo by setting the fifo_en bit to ?1? in control register 5 (0x24). after this operation the fifo buffer is enabled but isn?t collecting data, output registers are frozen to the last samples set loaded. 2. activate stream mode by setting the fn[1:0] field to ?10? in the fifo control register (0x2e). as described, for fifo mode, data can be retrieved when ovrn is set to?1? performing a 32 sample set reading from output registers, data can be retrieved also on the wtm flag if the application requires a smaller number of samples. !-v w ),)2prgh hqdeoh ),)2 vwrs 2951 ),)20rgh hqdeoh ),)25hdglqj 6wduw),)2 5hdglqj ),)2 %\sdvv ?   ?  ? ?       ? ) ) ) ) ? ) ? ? ) ) ) ) ) ) w vwrs 2951 ),)25hdglqj ?   ?  ? ?       ? ) ) ? ) ? ? ) ) ) ) ) )
AN3308 first in first out (fifo) buffer doc id 18198 rev 1 45/52 figure 25. stream mode fast reading behavior in stream mode, the fifo buffer is continuo usly filling (from f0 to f31) at the selected output data rate. when the buffer is full the ovrn flag goes up and the suggested solution is to read all fifo samples (192 bytes) faster then 1*odr, in order to make free fifo slots available for the new acceleration samples. this allows to avoid loss of data and to decrease the host processor interaction increasing system efficiency. if the reading procedure is not fast enough, three different cases can be observed: 1. fifo sample set (6 bytes) reading faster than 1*odr: data are correctly retrieved because a free slot is made available before new data is generated. 2. fifo sample set (6 bytes) reading synchronous to 1*odr: data are correctly retrieved because a free slot is made available before new data is generated but fifo benefits are not exploited. this case is equivalent to read data on data ready interrupt and does not reduce the host processor interaction compared to the standard accelerometer reading. 3. fifo sample set (6 bytes) reading slower than 1*odr: in this case some data is lost because data recovery is not fast enough to free slots for new acceleration data figure 26 . the number of correctly recovered samples is related to the difference between the current odr and the fifo sample set reading rate. figure 26. stream mode slow reading behavior !-v w 6wuhdp hqdeoh 2951 ),)25hdglqj 6wduw),)2 5hdglqj 6wduw),)2 5hdglqj ? ?    ?    ? ?       ? ? ) ) ) ? ) ) ) ? ? ) ) ) ) ) ) w 2951 ),)25hdglqj ? ?    ?    ? ?       ? ? ) ) ) ? ) ) ) ? ? ) ) ) ) ) ) !-v w 6wuhdp hqdeoh 2951 ),)25hdglqj 6wduw),)2 5hdglqj 6wduw),)2 5hdglqj   ? \\ [[ ?     nn o \\ mm o [[   ? ?     ? )" )" ? ) ) )  )" )" ) ) ? ? ) ) ) ) 6dpsohv ryhuzulwwhq w 2951 ),)25hdglqj   ? \\ [[ ?     nn o \\ mm o [[   ? ?     ? )" )" ? ) ) )  )" )" ) ) ? ? ) ) ) )
first in first out (fifo) buffer AN3308 46/52 doc id 18198 rev 1 in figure 26 , due to slow reading, data from ?jj? are not retrieved because they are replaced by the new accelero meter samples generated by the system. figure 27. stream mode slow reading zoom after stream mode enable, fifo slots are filled at the end of each odr time frame. the reading procedure must start as soon as the ovrn flag is set to ?1?, data are retrieved from fifo at the beginning of the reading operation. when a read command is sent to the device, the output registers content is moved to the spi/i 2 c register and the current oldest fifo value is shifted into the output registers in order to allow the next read operation. in the case of a reading slower than 1*odr, some data can be retrieved from fifo after that new sample is inserted into the addressed location. in figure 27 the fourth read command starts after the refresh of the f3 index and this generates a disconnect in the reading data. the ovrn flag advises the user that this event has taken place. in this example, three correct samples have been read, the number of correctly recovered samples is dependent on the difference between the current odr and the fifo sample set reading timeframe. 9.3.4 stream-to-fifo mode this mode is a combination of the stream and fifo modes described above. in stream-to- fifo mode, the fifo buffer starts operating in stream mode and switches to fifo mode when the selected interrupt occurs. follow these steps for stream-to-fifo mode configuration: 1. configure desired interrupt generator using register int1_cfg (0x30). 2. set tren bit in the fifo control register (0x2e) according to the configured interrupt generator: tren = ?0? in order to select interrupt 1, tren = ?1? in order to select interrupt 2. 3. turn on fifo by setting the fifo_en bit to ?1? in control register 5 (0x24). after this operation the fifo buffer is enabled but isn?t collecting data, output registers are frozen to the last samples set loaded. 4. activate stream-to-fifo mode by setting the fn[1:0] field to ?11? in the fifo control register (0x2e). the interrupt trigger is related to the ia bit in the int1_src register and it is generated even if the interrupt signal is not driven to an interrupt pad. mode switch is performed if both ia and ovrn bits are set high. stream-to-fifo mode is sensitive to the trigger level and not to the trigger edge, this means that if stream-to-fifo is in fifo mode and the interrupt !-v 6wuhdp hqdeoh w 2951 5 ),)25hdglqj 6wduw),)2 5hdg lqj 6dpsohv ryhuzulwwhq ? ?       ?      ? ? ) ) ) ) ) ) ? ) ) ) ) ) 5 5 5 5 w wgw wgw w 2951 5 ),)25hdglqj ? ?       ?      ? ? ) ) ) ) ) ) ? ) ) ) ) ) 5 5 5 5 w wgw wgw
AN3308 first in first out (fifo) buffer doc id 18198 rev 1 47/52 condition disappears, the fifo buffer returns to stream mode because the ia bit becomes zero. it is suggested to latch the interrupt sign al used as the fifo trigger in order to avoid losing interrupt events. if the selected interrupt is latched, it is needed to read the register int1_src to clear the ia bit; after reading, the ia bit takes 2*odr to go low. in stream mode the fifo buffer continues filling, when the buffer is full, the ovrn bit is set high and the next samples overwrite the oldest. when trigger occurs, two different cases can be observed: 1. if the fifo buffer is already full (ovrn = ?1 ?), it stops collecting dat a at the first sample after trigger. fifo content is composed of #30 samples collected before the trigger event, the sample that has generated the interrupt event and one sample after trigger. 2. if fifo isn?t yet full (initial transient), it contin ues filling until it is full (ovrn = ?1?) and then, if trigger is still presen t, it stops collecting data. figure 28. stream-to-fifo mode: interrupt not latched figure 29. stream-to-fifo mode: interrupt latched stream-to-fifo can be used in order to analyze the samples history that generate an interrupt; the standard operation is to read fifo content when fifo mode is triggered and fifo buffer is full and stopped. !-v 7uljjhu ,$elw w 6wuhdpwr),)2 hqdeoh ),)2 vw rs 2951 ),)25hdglqj 6wduw),)2 5h dglqj 2'5      ? ?       ) ) ) ,qwhuuxsworvw 7uljjhu ,$elw w 2951 ),)25hdglqj 2'5      ? ?       ) ) ) !-v 7uljjhu ,$elw w 6wuhdpwr),)2 hqdeoh ),)2 vwrs 2951 6wuhdpwr),)2 hqdeoh 5hdg ,1765& ),)25hdglqj 6wduw),)2 5hdglqj ),)2 %\sdvv   ? ?       ) ) ) ) ) ) ) ) ) ) 7uljjhu ,$elw w 2951 ),)25hdglqj   ? ?       ) ) ) ) ) ) ) ) ) )
first in first out (fifo) buffer AN3308 48/52 doc id 18198 rev 1 9.4 watermark watermark is a configurable flag that can be used to generate specific interrupt in order to know when the fifo buffer contains at least the number of samples defined as the watermark level. the user can select the desired level in a range from 0 to 31 using the fth[4:0] field in the fifo control register while the fifo source register fss[4:0] always contains the number of samples stored in fifo. if fss[4:0] is greater than fth[4:0], the wtm bit is set high in the fifo source register, on the contrary, wtm is driven low when the fss[4:0] field becomes lower than fth[4:0]. fss[4:0] increases by one step at the odr frequency and decreases by one step every time that a sample set reading is performed by the user. figure 30. watermark behavior - fth[4:0] = 10 in figure 30 , the first row indicates the fss[4:0] value, the second row indicates the relative fifo slot and last row shows the incremental fifo data. assuming fth[4:0] = 10, the wtm flag changes from ?0? to ?1? when the eleventh fifo slot is filled (f10). figure 31 shows that the wtm flag goes down when the fifo content is less than fth[4:0], it means that nine unread sample sets remain in fifo. the watermark flag (wtm) can be enabled to generate a dedicated interrupt on the int1 pin by setting the i1_wtm bit high in ctrl_reg3. 9.5 retrieve data from fifo when fifo is enabled and the mode is different to bypass, reading output registers (28h to 2dh) return the oldest fifo sample set. whenever output registers are read, their content is moved to the spi/i 2 c output buffer. fifo slots are ideally shifted up one level in order to release room for a new sample reception and output registers load the current oldest value stored in the fifo buffer. the whole fifo content is retrieved performing thirty two read operations from accelerometer output registers, every other reading operation returns the same last value until a new sample set is available in the fifo buffer. !-v w ),)2 hqdeoh 2951   2951  ?    ? ?          ? ?   ? ?       ) ) ) ? ? ) ) ? ? ) ) ) ) ) ) :70 ),)25hdglqj 6wduw),)2 5hdglqj w 2951   2951  ?    ? ?          ? ?   ? ?       ) ) ) ? ? ) ) ? ? ) ) ) ) ) ) :70 ),)25hdglqj
AN3308 first in first out (fifo) buffer doc id 18198 rev 1 49/52 data can be retrieved from fifo using every reading byte combination in order to increase the application flexibility (ex: 196 single byte reading, 32 reading of 6 bytes, 1 multiple reading of 196 bytes, etc.). it is suggested to read all fifo slots in a mu ltiple byte reading of 196 bytes (6 output registers by 32 slots) faster than 1*odr. in order to minimize communication between master and slave the reading address is automatically updated by the device; it rolls back to 0x28 when register 0x2d is reached. in order to avoid losing data, the right odr must be selected according to the serial communication rate available. in the case of standard i 2 c mode being used (max rate 100 khz), a single sample set reading takes 830 s while total fifo download is about 17.57ms. i 2 c speed is lower than spi and it needs about 29 clock pulses to start communication (start, slave address, device address+writ e, restart, device address+read) plus an additional 9 clock pulses for every byte to read. if this suggestion were followed, the complete fifo reading would be performed faster than 1*odr, this means that using a standard i 2 c, the selectable odr must be lower than 57 hz. if a fast i 2 c mode is used (max rate 400 khz), the selectable odr must be lower than 228 hz. figure 31. fifo reading diagram - fth[4:0] = 10 in figure 31 ?rx? indicates a 6-byte reading operation and ?f0*? represents a single odr slot stretched for diagram convenience. !-v w ),)2 hqdeoh 2951 ?    2951 ?  ?  ?     ?  ?  ? ) ) ) ) ? ) ? ) :70 5 ),)25hdglqj 6wduw),)2 5hdglqj 5 ? ? 5 ? ? 5 5 5   ? ?  ?  (037< ),)2(psw\  (037<  ?  ?    2951 ?  ?  ?     ?  ?  ? ) ) ) ) ? ) ? ) 5 5 ? ? 5 ? ? 5 5 5   ? ?  ?  (037<   ? 
auxiliary adc AN3308 50/52 doc id 18198 rev 1 10 auxiliary adc the lis3dh is provided with an au xiliary 10-bit adc converter multiplexed on the adc1, adc2, and adc3 input pins of the device, therefore allowing the conversion of external analog signals, such as analog output gyroscopes, to the digital world. the digitized data can then be read from the device by reading registers out_adc1_l, out_adc1_h, out_adc2_l, out_adc2_h, out_adc3_l, an d out_adc3_h. the conversion status is reported in the status_aux (07h) regist er; when auxiliary adc data are ready, the 321da bit of the status_aux register is set to 1. the status of the 321da bit can be driven to the int1 pad by setting the i1_dry2 bit of ctrl_reg3 to 1. the auxiliary adc is enabled by setting the adc_pd bit of temp_cfg_reg (1fh) to 1. 10.1 temperature sensor the lis3dh is supplied with an internal temperature sensor. temperature data can be enabled by setting the temp_en bit of the temp_cfg_reg register to 1. when the auxiliary adc and temperature sensor are enable d, the third channel of the adc is used to digitize temperature sensor output and can be read inside the out_3_l and out_3_h registers as 2?s complement data.
AN3308 revision history doc id 18198 rev 1 51/52 11 revision history table 40. document revision history date revision changes 14-jan-2011 1 initial release.
AN3308 52/52 doc id 18198 rev 1 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2011 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN3308

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X